//
//  BaseTableViewController.swift
//  SinaMicroblog
//
//  Created by 唐绍禹 on 15/7/28.
//  Copyright © 2015年 唐绍禹. All rights reserved.
//

import UIKit

class BaseTableViewController: UITableViewController,VisitorLoginViewDelegate {


    
    //var userLogin = UserAccount.loadAccount() != nil
    var userLogin = UserAccount.userLogin
    
    var visitorLoginView: VisitorLoginView?

    override func loadView() {
        userLogin ? super.loadView() : setupVisitorView()
    }
    
    func visitorLoginViewWillLogin() {
        let nav = UINavigationController(rootViewController: OAuthViewController())
        
        presentViewController(nav, animated: true, completion: nil)
    }
    func visitorLoginViewWillRegister() {
        print("注册")
    }
    
    private func setupVisitorView() {
        //设置状态栏
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "登录", style: UIBarButtonItemStyle.Plain, target: self, action: "visitorLoginViewWillLogin")
        
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "注册", style: UIBarButtonItemStyle.Plain, target: self, action: "visitorLoginViewWillRegister")
        
        visitorLoginView = VisitorLoginView()
        visitorLoginView?.delegate = self
        view = visitorLoginView
        
        
        
    }
}
